package cn.itcast.nems.studentrecord.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 高昌露
 */

@AllArgsConstructor
@Getter
public enum QueryRangeTypeEnum {
    MY_COMMIT("我提交的"),
    WAIT_APPROVAL("待办凭单"),
    APPROVED("已办凭单"),
    ALL("全部凭单"),
    ;
    private final String desc;

    /**
     * 根据名称匹配枚举
     *
     * @param name 枚举名称
     * @return cn.itcast.nems.order.enumeration.QueryRangeType 审批范围枚举
     * @throws IllegalArgumentException 枚举名称匹配错误时抛出异常
     * @author 高昌露
     * @since 2023/12/20 17:33
     */
    public static QueryRangeTypeEnum of(String name) throws IllegalArgumentException {
        QueryRangeTypeEnum rangeTypeEnum;
        try {
            rangeTypeEnum = QueryRangeTypeEnum.valueOf(name);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(String.format("审批范围类型[%s]不存在或错误！", name));
        }
        return rangeTypeEnum;
    }
}
